<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.tjsinfo.tjsoa.common.TestRiQi"%>
<%@page import="com.tjsinfo.tjsoa.common.DateTimeFromConver"%>
<%@page import="com.tjsinfo.tjsoa.meetingroom.vo.MeetingRoomEmploy"%>
<%@page import="java.text.SimpleDateFormat"%>
<%
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
		Date date = (Date)request.getAttribute("yueli");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月");
		
		Map map = (Map)request.getAttribute("roomMap");
		Map listmap = (Map)request.getAttribute("listmap");
		
		List ReUseList = (List)request.getAttribute("ReUseList");
		String roomId = (String)session.getAttribute("roomId");
		session.setAttribute("roomId",roomId);
		int start = 0;
		String[] week = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>"/>
<link rel="stylesheet" type="text/css" href="<%=basePath %>ext-2.1/resources/css/ext-all.css" />
<script type="text/javascript" src="<%=basePath %>ext-2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=basePath %>ext-2.1/ext-all.js"></script>
<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css"/>


<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>天津市粮油集团有限公司</title>
<script type="text/javascript" >

</script>
<style >
	.contact_content {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1800;
			overflow: auto;
		}
		.black_overlays{
			display: none;
			position: absolute;
			top: 0%;
			left: 0%;
			width: 100%;
			height: 100%;
			background-color: #C1EBFC;
			z-index:1002;
			-moz-opacity: 0.8;
			opacity:.80;
			filter: alpha(opacity=30);
		}
	
</style>
<style>
#container {
		    width:600px;
		    height:300px;
		    border:3px solid #c3daf9;
		}
		
.calendar {
    background-image:url(<%=basePath%>images/icon_64.gif) !important;
}

.blist {
    background-image: url(<%=basePath%>images/icon_64.gif) !important;
}

.bmenu {
    background-image: url(<%=basePath%>images/ju.gif) !important;
}

.menu-title{
    background: #ebeadb url(<%=basePath%>images/icon_64.gif) repeat-x;
    border-bottom:1px solid #99bbe8;
    color:#15428b;
    font:bold 10px tahoma,arial,verdana,sans-serif;
    display:block;
    padding:3px;
}
.lan01{
background: url(images/lanbg01.gif) no-repeat 0 0; width:6px; height:24px;} 
.lan02{
background: url(images/lanbg02.gif) repeat-x; width:99%; height:24px;}            
.lan03{
background: url(images/lanbg03.gif) no-repeat; width:8px; height:24px;}             
.cha{
padding-top:3px}           
</style> 
	<link href="<%=basePath %>ajaxFramework/ext-2.1/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all.js"></script>
    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
    
    <script type='text/javascript' src='<%=basePath%>dwr/interface/MeetingRoomEmployBo.js'></script>
	<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
	<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
<script type="text/javascript">
	function isTrueDate(time){
	    document.getElementById('riqistr').value = time;
	    MeetingRoomEmployBo.isTrueDate(time,isTrueDateAfter);
	}
	function isTrueDateAfter(data){
			var time=document.getElementById('riqistr').value;
	       if(data)
	   	{
	   	   window.location.href='<%=basePath%>tjsinfo/tjsoa/meetingroom/newRoomEmpoly.do?time='+time+'&year=<%=date.getYear()+1900 %>&month=<%=date.getMonth()+1 %>&roomId=<%=roomId %>';
	   	}
	    else
	   	{
		   Ext.MessageBox.alert('提示框','<nobr>已超过当前日期,无法预定</nobr>');
	   	   return;	
	   	}
	}
				
	function initWH(){
    	document.getElementById('indexDiv').style.height = document.body.clientHeight-40+"px";
   	}
   	
   	window.onload = function(){
   		initWH();
		var tb = new Ext.Toolbar(
			{
				height:25
			}
		);
	
	    tb.render('menu');
		tb.add(
	    {
	            text:'返回',
	            iconCls: 'daohang',
	        	handler: function(){
	        		window.location.href = '<%=basePath %>tjsinfo/tjsoa/meetingroom/applicationMeetingRoom.do';
				}
	    }
	    );
		tb.addFill();
	    tb.addText('<img id="windowResize" src="<%=basePath%>images/m_icon05.gif;"><a style="font-weight:bold; color:black;line-height: 22px;">会议申请</a>&nbsp;&nbsp;&nbsp;');
	}
</script>
</head>
<body>
<div id="right">
<div style="height:91%;">
	  <div id="menu" style="padding-top:4px;"></div>
      <form name="form1" method="post" id="form1">
      <div id="indexDiv">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" style="height: 580px;">
          <tr>
            <td width="100%" valign="top" height="100%">
               <div class="contabwd">
                 <div id="plan_month">
                    <!--周记录-->
                    <div class="plan_div" >
                            <table width="100%" border="0" class="page">
                        <tr>
                          <td width="20%">&nbsp;</td>
                          <td width="10%"><a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/returnUpCalendar.do?date=<%=DateTimeFromConver.zhuanhuariqi(date) %>&id=<%=roomId %>" class="a1">上一月</a></td>
                          <td width="3%">&nbsp;</td>
                          <td width="31%"><strong><%=sdf.format(date)%></strong></td>
                          <td width="17%"><a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/returnDownCalendar.do?date=<%=DateTimeFromConver.zhuanhuariqi(date) %>&id=<%=roomId %>" class="a2">下一月</a></td>
                          <td width="16%">&nbsp;</td>
                        </tr>
                      </table>
                     <table border="0" cellspacing="0" class="tab_list01">
                        <tr>
                          <th>星期日 </th>
                          <th>星期一</th>
                          <th>星期二</th>
                          <th>星期三</th>
                          <th>星期四</th>
                          <th>星期五</th>
                          <th>星期六</th>
                        </tr>
                        <tr >
        <%
     		date.setDate(1);
     		for(int i =1,u=0;i!=u;i++)
     		{
     		%>
				<%
					String riqistr = DateTimeFromConver.zhuanhuariqi(date);
					for(int a = 0;a<7&&start == 0;a++)
					{
						
							if(TestRiQi.jishuxingqi(riqistr).equals(week[a]))//没日子的
							{
								start = 1;
								break;
							}
							else
							{
								i++;
					%>
						 <td class="color" >&nbsp;</td>
					<% 			
							}
							
					}
					if(start == 1)
					{
						if(map.get(DateTimeFromConver.datetostr(riqistr)) == null)//没会议的
						{
							
						
					%>
		  <td align="center" >
		  <h2><%=riqistr %></h2>
		  <a href="javascript:isTrueDate('<%=riqistr %>')">
		  <input type="hidden" id="riqistr" name="riqistr" value="<%=riqistr %>" />
		  <img src="images/wu.gif" />	
		  </a>
		  </td>
		<%
						}	
						else //有会议
						{
							MeetingRoomEmploy roomEmpoly = (MeetingRoomEmploy)map.get(DateTimeFromConver.datetostr(riqistr));
							List<MeetingRoomEmploy> numList = (List<MeetingRoomEmploy>)listmap.get(riqistr);
							if(numList==null)numList = new ArrayList<MeetingRoomEmploy>();
							if("0".equals(roomEmpoly.getState()) && numList.size()==1)//一个拒绝会议
							{	
		%>
		   <td class="green">
		  <h2><%=riqistr %></h2>
		  <a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/reUseLink.do?time=<%=riqistr %>&year=<%=date.getYear()+1900 %>&month=<%=date.getMonth()+1 %>&roomId=<%=roomId %>">
		  <%
		  if("全天".equals(roomEmpoly.getRemarks())){
			  out.print("拒绝会议(全天1)");
		  }else if("上午".equals(roomEmpoly.getRemarks())){
			  out.print("拒绝会议(上午1)");
		  }else if("下午".equals(roomEmpoly.getRemarks())){
			  out.print("拒绝会议(下午1)");
		  }
		  %>
		  </a>	
		  </td>
		<% 					}
							//else if("1".equals(roomEmpoly.getState()) && "0".equals(roomEmpoly.getReUse()))
							else if("1".equals(roomEmpoly.getState()) && numList.size()==1)//单个审批通过会议
							{
		%>
		  <td class="green" >
		  <h2><%=riqistr %></h2>
		 <a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/againEmpolyLink.do?time=<%=riqistr %>&year=<%=date.getYear()+1900 %>&month=<%=date.getMonth()+1 %>&roomId=<%=roomId %>">
		  <%
		  if("全天".equals(roomEmpoly.getRemarks())){
			  out.print("成功预订(全天1)");
		  }else if("上午".equals(roomEmpoly.getRemarks())){
			  out.print("成功预订(上午1)");
		  }else if("下午".equals(roomEmpoly.getRemarks())){
			  out.print("成功预订(下午1)");
		  }
		  %></a>
		  </td>	
		<% 						
							}	
							//else if("2".equals(roomEmpoly.getState())&& "0".equals(roomEmpoly.getReUse()))
							else if("2".equals(roomEmpoly.getState())&& numList.size()==1)
							{
		%>	
		  <td class="green">
		  <h2><%=riqistr %></h2>
		  <a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/againEmpolyLink.do?time=<%=riqistr %>&year=<%=date.getYear()+1900 %>&month=<%=date.getMonth()+1 %>&roomId=<%=roomId %>">
		  <%
		  if("全天".equals(roomEmpoly.getRemarks())){
			  out.print("已使用(全天1)");
		  }else if("上午".equals(roomEmpoly.getRemarks())){
			  out.print("已使用(上午1)");
		  }else if("下午".equals(roomEmpoly.getRemarks())){
			  out.print("已使用(下午1)");
		  }
		  %>
		  </a>	
		  </td>	
		  <% }
							//else if("3".equals(roomEmpoly.getState())&& "0".equals(roomEmpoly.getReUse()))
							else if("3".equals(roomEmpoly.getState())&& numList.size()==1)//单个待审批会议
							{%>	
		  <td class="green">
		  <h2><%=riqistr %></h2>
		  <a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/againEmpolyLink.do?time=<%=riqistr %>&year=<%=date.getYear()+1900 %>&month=<%=date.getMonth()+1 %>&roomId=<%=roomId %>">
		  <%
		  if("全天".equals(roomEmpoly.getRemarks())){
			  out.print("待审批(全天1)");
		  }else if("上午".equals(roomEmpoly.getRemarks())){
			  out.print("待审批(上午1)");
		  }else if("下午".equals(roomEmpoly.getRemarks())){
			  out.print("待审批(下午1)");
		  }
		  %>
		  </a>	
		  </td>		<% }	
							//else if(ReUseList.size() == 1 || ReUseList.size() > 1)
							else if(numList.size() > 1)//多会议
							{
							int jujue = 0;
							int yuding = 0;
							int dai = 0;
							int yong = 0;
							int quantianjujue = 0;
							int quantianyuding = 0;
							int quantiandai = 0;
							int quantianyong = 0;
							int shangwujujue = 0;
							int shangwuyuding = 0;
							int shangwudai = 0;
							int shangwuyong = 0;
							int xiawujujue = 0;
							int xiawuyuding = 0;
							int xiawudai = 0;
							int xiawuyong = 0;
							for (Iterator iterator = numList.iterator(); iterator.hasNext();) {
								MeetingRoomEmploy employ = (MeetingRoomEmploy) iterator.next();
								if("全天".equals(employ.getRemarks())){
									if("0".equals(employ.getState())){
										quantianjujue++;
										jujue++;
									}else if("1".equals(employ.getState())){
										quantianyuding++;
										yuding++;
									}else if("3".equals(employ.getState())){
										quantiandai++;
										dai++;
									}else if("2".equals(employ.getState())){
										quantianyong++;
										yong++;
									}
								}else if("上午".equals(employ.getRemarks())){
									if("0".equals(employ.getState())){
										shangwujujue++;
										jujue++;
									}else if("1".equals(employ.getState())){
										shangwuyuding++;
										yuding++;
									}else if("3".equals(employ.getState())){
										shangwudai++;
										dai++;
									}else if("2".equals(employ.getState())){
										shangwuyong++;
										yong++;
									}
								}else if("下午".equals(employ.getRemarks())){
									if("0".equals(employ.getState())){
										xiawujujue++;
										jujue++;
									}else if("1".equals(employ.getState())){
										xiawuyuding++;
										yuding++;
									}else if("3".equals(employ.getState())){
										xiawudai++;
										dai++;
									}else if("2".equals(employ.getState())){
										xiawuyong++;
										yong++;
									}
								}
							}
							%>	
		  <td class="green">
		  <h2><%=riqistr %></h2>
		 <a href="<%=basePath%>tjsinfo/tjsoa/meetingroom/reUseLink.do?time=<%=riqistr %>&year=<%=date.getYear()+1900 %>&month=<%=date.getMonth()+1 %>&roomId=<%=roomId %>">
		 <%
		 	if(yong>0){
		 %>
		 	已使用(<%if(quantianyong>0)out.print("全天"+quantianyong+"&nbsp;");if(shangwuyong>0)out.print("上午"+shangwuyong+"&nbsp;");if(xiawuyong>0)out.print("下午"+xiawuyong+"&nbsp;"); %>)<br/>
		 <%
			}
		 %>
		 <%
		 	if(yuding>0){
		 %>
		 	成功预订(<%if(quantianyuding>0)out.print("全天"+quantianyuding+"&nbsp;");if(shangwuyuding>0)out.print("上午"+shangwuyuding+"&nbsp;");if(xiawuyuding>0)out.print("下午"+xiawuyuding+"&nbsp;"); %>)<br/>
		 <%
			}
		 	if(dai>0){
		 %>
		 	待审批(<%if(quantiandai>0)out.print("全天"+quantiandai+"&nbsp;");if(shangwudai>0)out.print("上午"+shangwudai+"&nbsp;");if(xiawudai>0)out.print("下午"+xiawudai+"&nbsp;"); %>)<br/>
		 <%
			}
		 	if(jujue>0){
		 %>
		 	拒绝会议(<%if(quantianjujue>0)out.print("全天"+quantianjujue+"&nbsp;");if(shangwujujue>0)out.print("上午"+shangwujujue+"&nbsp;");if(xiawujujue>0)out.print("下午"+xiawujujue+"&nbsp;"); %>)<br/>
		 <%
			}
		  %>
		  </a>	
		  </td>		
		<% 
						}	
			}
			
				}	
		%>
       	
		<% 	
     		if(i%7==0)
     		{
     	     %>
			</tr>
			
			<% 	
     		}
     			int a = date.getMonth();
     			date = TestRiQi.afterNDay(date,1);
     			if(a != date.getMonth())
     			{
     				u = i + 1;
     			}
     		}
     		
     	   %>
                      </table>
                   </div>
                </div>
              </div>
            </td>
          </tr>
      </table>
      </div>
          </form>
</div>
</div>
</body>  
 
</html>
